package com.rran.study.designpattern.behavioral.command;

import com.rran.study.designpattern.behavioral.command.command.Command;
import com.rran.study.designpattern.behavioral.command.command.CompositeCommand;
import com.rran.study.designpattern.behavioral.command.command.NeedBartenderCommand;
import com.rran.study.designpattern.behavioral.command.command.NeedCookCommand;
import com.rran.study.designpattern.behavioral.command.invoke.Invoker;
import com.rran.study.designpattern.behavioral.command.invoke.Waiter;

public class Client {

    public static void main(String[] args) {
        Command cookCommand = new NeedCookCommand();
        Command drinkCommand = new NeedBartenderCommand();
        // 执行需要食物命令
        Invoker waiter1 = new Waiter(cookCommand);
        Invoker waiter2 = new Waiter(drinkCommand);
        waiter1.action();
        waiter2.action();

        System.out.println("组合命令");
        // 复合逻辑  同时叫食物和酒
        CompositeCommand compositeCommand = new CompositeCommand();
        compositeCommand.addCommand(cookCommand);
        compositeCommand.addCommand(drinkCommand);
        compositeCommand.execute();
    }
}
